package redis.listener.demo;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * @author linzp
 * @version 1.0.0
 * CreateDate 2021/1/29 9:20
 */
@RestController
public class PublishService {

    //这里我使用stringRedisTemplate
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    //这里使用convertAndSend方法，参数为 channel 通道和内容
    @GetMapping("/publish")
    public void sendMsg(String channel, String msg) {
        stringRedisTemplate.convertAndSend(channel, msg);
    }

}
